from django.db import models
import datetime

# 用户
class User(models.Model):
    password = models.CharField(max_length=264, verbose_name='密码')
    username = models.CharField(max_length=20, verbose_name='用户名')
    mobile = models.CharField(max_length=11, verbose_name='手机号')
    sex = models.CharField(max_length=2, verbose_name='性别',default='男')
    id_number = models.CharField(max_length=18,default='', verbose_name='身份证号')
    # user = models.BooleanField(default=False, verbose_name='用户开关')
    # shop_user = models.BooleanField(default=False, verbose_name='商家开关')
    # todo 前端通过判断123实现展示不同的内容
    id_type = models.IntegerField(choices=((1,'用户'),(2,'商家'),(3,'骑手')),default=1,verbose_name='1.用户,2.商家,3.棋手')
    info = models.CharField(max_length=64,default='用户太懒啦还没有具体描述！', verbose_name='描述')
    # work_shop = models.IntegerField(default=0,verbose_name='店铺id')
    create_time = models.DateTimeField("注册时间", default=datetime.datetime.now())

    class Meta:
        db_table = 'user'

# 地址表
class Address(models.Model):
    address = models.CharField(max_length=128, verbose_name="收货地址")
    address_detailed = models.CharField(max_length=128, verbose_name="收货地址具体位置")
    longitude = models.DecimalField(max_digits=10, decimal_places=6, verbose_name="经度")
    latitude = models.DecimalField(max_digits=10, decimal_places=6, verbose_name="维度")
    is_atter = models.IntegerField(verbose_name='是否默认1:默认,0:未选', default=0)
    # 外键关联
    user_id = models.ForeignKey(User,on_delete=models.CASCADE,verbose_name='用户')


    class Meta:
        db_table = 'address'


# 口味表
class Taste(models.Model):
    name = models.CharField(max_length=10, verbose_name='口味', default='')
    # 外键关联
    user_id = models.ForeignKey(User,on_delete=models.CASCADE,verbose_name='用户',related_name='taste_user')

    class Meta:
        db_table = 'taste'







